﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace Tesla.Util.Utilities
{
    public class GADNCustomException :  ApplicationException
    {
        #region "Properties"

        public string ClassName
        {
            get { return m_ClassName; }
            set { m_ClassName = value; }
        }
        private string m_ClassName;
        public string ErrorMessage
        {
            get { return m_ErrorMessage; }
            set { m_ErrorMessage = value; }
        }
        private string m_ErrorMessage;
        public string MethodName
        {
            get { return m_MethodName; }
            set { m_MethodName = value; }
        }
        private string m_MethodName;
        public int ErrorNumber
        {
            get { return m_ErrorNumber; }
            set { m_ErrorNumber = value; }
        }

        private int m_ErrorNumber;
        #endregion

        #region "Constructor"

        public GADNCustomException()
            : base()
        {
        }

        public GADNCustomException(string message)
            : base(message)
        {
        }

        public GADNCustomException(string message, string className, string methodName, Exception innerException)
            : base(message, innerException)
        {
            this.ClassName = className;
            this.MethodName = methodName;
            this.ErrorMessage = message;
        }

        public GADNCustomException(string message, string className, string methodName, int errorNumber)
            : base(message)
        {
            this.ClassName = className;
            this.MethodName = methodName;
            this.ErrorMessage = message;
            this.ErrorNumber = errorNumber;
        }

        public GADNCustomException(string message, string className, string methodName)
            : base(message)
        {
            this.ClassName = className;
            this.MethodName = methodName;
            this.ErrorMessage = message;
        }

        #endregion

        #region "Public Methods"

        /// <summary>
        /// To generate custom exception message from the assigned values
        /// (Will be used in the case of throw an exception according to the db return value.
        /// </summary>
        /// <returns>Custom exception message generated from the assigned values.</returns>
        public string GenerateCustomExceptionMessage()
        {
            System.Text.StringBuilder exceptionMessage = new System.Text.StringBuilder();
            exceptionMessage.Append("An error occurred in Class:" + ClassName + ", Method:" + MethodName + ", Message :" + Message);
            return exceptionMessage.ToString();
        }

        #endregion
    }
}
